{%  extends "admin/common/admin_base.html" %}
{% block title -%}
    操作员管理
{% endblock %}
{% block page_title -%}操作员管理{% endblock %}
{% block page_btn_name -%}操作员列表{% endblock %}
{% block content -%}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <h3 class="box-title"></h3>
                    <div class="pull-left">
                        {{authAction(url_for('adminadmin.add'), 'create')}}
                        {{authAction(url_for('adminadmin.delete'),cationType='delete_all')}}
                    </div>
                        {% include 'admin/common/search.html' %}
                </div>
                <div class="box-body table-responsive">
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th width="35"><input type="checkbox" class="minimal checkbox-toggle"></th>
                            <th>id{{ table_sort('id')|safe  }}</th>
                            <th>姓名</th>
                            <th>图像</th>
                            <th>角色</th>
                            <th>帐号{{ table_sort('account')|safe  }}</th>
                            <th>性别</th>
                            <th>状态</th>
                            <th>上一次登陆时间{{ table_sort('_last_time')|safe  }}</th>
                            <th width="202">操作</th>
                        </tr>
                        {% for v in data.items -%}
                        <tr>
                            <td style="vertical-align:middle"><input type="checkbox" name="id[]" value="{{ v.id }}" class="minimal"></td>
                            <td style="vertical-align:middle">{{ v.id }}</td>
                            <td style="vertical-align:middle"><span class="editable" data-pk="{{ v.id }}" data-name="admin_name" data-url="{{ url_for('adminadmin.edit',id=v.id) }}" >{{ v.admin_name }}</span></td>
                            <td style="vertical-align:middle"><img src="{{ default_img(v.img)}}" style="width:40px;border-radius:40%;" /></td>
                            <td style="vertical-align:middle">{{ v.roles.first().role_name }}</td>
                            <td style="vertical-align:middle"><span class="editable" data-pk="{{ v.id }}" data-name="account" data-url="{{ url_for('adminadmin.edit',id=v.id) }}" >{{ v.account }}</span></td>
                            <td style="vertical-align:middle">
                                <a href="javascript:void(0);" data-id="{{ v.id }}" data-field="sex"
                                data-value="{{ v.sex }}" data-url="{{ url_for('adminadmin.edit',id=v.id) }}"
                                class='editimg sex fa {% if v.sex == 1 %}fa-male text-green{% else %}fa-female text-red{% endif %}'></a>
                            </td>
                            <td style="vertical-align:middle">
                                <a href="javascript:void(0);" data-id="{{ v.id }}" data-field="state"
                                data-value="{{ v.state }}" data-url="{{ url_for('adminadmin.edit',id=v.id) }}"
                                class='editimg state fa {% if v.state == 1 %}fa-check-circle text-green{% else %}fa-times-circle text-red{% endif %}'></a>
                            </td>
                            <td style="vertical-align:middle">{{ v.last_time }}</td>
                            <td style="vertical-align:middle">{{authAction(url_for('adminadmin.edit',id=v.id), 'edit')}}  {{authAction(url_for('adminadmin.delete'),cationType='delete',param=v.id)}} </td>
                        </tr>
                        {%- endfor %}
                    </table>
                </div>
                    {{ render_page_data(data,'adminadmin.index') }}
            </div>
        </div>
    </div>
</section>
    <script type="text/javascript">
        $(function(){
            /*ajax页面加载icheck，有该控件的页面才需要*/
            $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
                checkboxClass: 'icheckbox_minimal-blue',
                radioClass: 'iradio_minimal-blue'
            });

            /*ajax页面加载icheck，有该控件的页面才需要*/
            $(".select2").select2({language:"zh-CN"});

            /*全选-反选*/
            $('.checkbox-toggle').on('ifChecked', function(event){
                var _this = $(this);
                var _table = _this.closest('.table');
                _table.find("tr td input[type='checkbox']").iCheck("check");
            });
            $('.checkbox-toggle').on('ifUnchecked', function(event){
                var _this = $(this);
                var _table = _this.closest('.table');
                _table.find("tr td input[type='checkbox']").iCheck("uncheck");
            });

            $('.editable').editable({
                emptytext: "empty",
                params: function(params) {      //参数
                    var data = {};
                    data['id'] = params.pk;
                    data[params.name] = params.value;
                    return data;
                },
                success: function(response, newValue) {
                    var res = response;
                    if(res.code == 200){

                    }else{
                        return res.info;
                    }
                }
            });
        })
    </script>
{% endblock %}